const app = getApp();
Page({
    data: {
        OrderList:[],
        StatusBar: app.globalData.StatusBar,
        CustomBar: app.globalData.CustomBar,
        TabbarBot: app.globalData.tabbar_bottom,
        TabCur: 0,scrollLeft:0,
        SortMenu: [{id:0,name:"全部订单"},{id:1,name:"待付款"},{id:2,name:"待发货"},{id:3,name:"待收货"},{id:4,name:"已完成"}]
    },
    onLoad: function (options) {
        let _this = this;
        wx.getStorage({
          key: 'user',
          success: function (res) {
            console.log("取出用户名为")
            console.log(res.data); // 输出：value
            _this.setData({
              uid: res.data.data.uid
            })
          }
        });
        this.AllOrders()
    },

    tabSelect(e) {
        this.setData({
            TabCur: e.currentTarget.dataset.id,
            scrollLeft: (e.currentTarget.dataset.id-1)*60
        })
        this.AllOrders()
    },

    AllOrders:function(){
      let _this = this
      console.log(_this.data.TabCur)
      wx.getStorage({
        key: 'user',
        success: function (res) {
          wx.request({
            method:"GET",
            url: 'http://localhost:8989/order/findOrders/' + res.data.uid,
            data:{
              start: _this.data.TabCur,
              orderid: "1112221889740830"
            },
            success:(res => {
              console.log("得到的数据位：")
              _this.setData({
                OrderList:res.data.data
              })
              console.log(_this.data.OrderList)
            })
          })
        }
      });
    }
});
